msy.controller('LeftmenuController', function($scope, $http,$location,$rootScope,$timeout) {
	$scope.menus = [];
	$scope.getMenuList = function(){
		$http.get(
			'/api/getMenuList'
		).success(function(res){
			$scope.menus = res.data;
		}).error(function(res){
			console.log(res);
		});
	}
	
	$scope.getOnlineSupportList = function(){
		$http.get(
			'/api/getOnlineSupportList'
		).success(function(res){
			$scope.support = res.data;
		}).error(function(res){
			console.log(res);
		});
	}
	
	$scope.getMenuList();
	
	$scope.getOnlineSupportList();
	
	$scope.getItemOfMenu = function(index,id,type_cat){
		if(type_cat == "cha" && $scope.menus[index].sub_menu.length > 0){
			
			if($scope.menus[index]){
				$scope.menus[index].showSub = !$scope.menus[index].showSub;
			}
		}else{
			if(type_cat == "con"){
			
			}
		}
	}
});

msy.controller('MainController', function($scope, $http) {
	$scope.total= 0;
	$scope.limit = 9;
	$scope.curPage = 1;
	
	$scope.getProductList = function(){
		$http.get( '/api/getAllProduct?page='+$scope.curPage+'&limit='+$scope.limit
		).success(function(res){
			$scope.total = res.total;
			$scope.productList = res.data;
		});
	}
	
	$scope.getProductList();
	
});

msy.controller('DetailProductController', function($scope, $http, $state, $stateParams) {
	$scope.currentImage = "";
	$scope.getDetailProduct = function(){
		$http.get(
			'/api/getDetailProduct?id='+$stateParams.idproduct
		).success(function(res){
			$scope.record = res.data;
			$scope.currentImage = res.data.image1;
		}).error(function(res){
			console.log(res);
		});
	}
	
	$scope.getDetailProduct();
	
	$scope.getCurrentImage = function(imageId){
		$scope.currentImage = imageId;
	};
});
